package student.category.service;

import java.sql.SQLException;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;

import student.category.dao.CategoryDAO;

public class CategoryService {

	private CategoryDAO dao;
	
	public CategoryService(CategoryDAO dao) {
		this.dao = dao;
	}
	
	public List getMajorCategory(String groupId) throws SQLException {
		return dao.selectMajorCategory(groupId);
	}
	
	public String getMajorCategoryJSON(String groupId) throws SQLException, JSONException {
		List list = getMajorCategory(groupId);
		JSONArray jArr = new JSONArray(list);
		
		return jArr.toString();
	}
	
	public List getGroupCategory() throws SQLException {
		return dao.selectGroupCategory();
	}
}
